<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"

      xmlns:f="http://java.sun.com/jsf/core">
    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <h:form>
                <p:growl id="msg" life="3000"/>
                <h1 class="title">Natureza Escritura</h1>
                <p:tabView activeIndex="#{managerSearchNature.position.indexTab}"> 
                    <p:tab title="Novo" id="tab01">
                        <div class="row">
                            <div class="twelve columns"> 
                                <fieldset>
                                    <legend> <h4 style="margin:0 0 10px 0">Cadastro</h4></legend>
                                    <div class="container_24 clearfix " >
                                        <p:outputLabel value="Código: " styleClass="grid_3" />
                                        <p:inputText value="#{managerNatureWriting.natureWriting.cod}" styleClass="grid_8"/>

                                        <p:outputLabel value="Tipo Ato: " styleClass="grid_4"/>
                                        <p:autoComplete styleClass="grid_8" style="width: 28.44%" dropdown="true" converter="actcepconverter"   
                                                        var="actCepValue" itemLabel="#{actCepValue.description}" 
                                                        itemValue="#{actCepValue}" value="#{managerNatureWriting.natureWriting.actCep}"
                                                        completeMethod="#{managerActCep.autocomplete}" />

                                        <p:outputLabel value="Descrição: " styleClass="grid_3"/>
                                        <p:inputTextarea value="#{managerNatureWriting.natureWriting.description}" styleClass="grid_20" />

                                    </div>
                                </fieldset>
                            </div>
                            <div class="buttonAction">
                                <p:commandButton value="Salvar" actionListener="#{managerNatureWriting.create()}"
                                                 icon="ui-icon-disk" styleClass="ui-priority-primary"
                                                 update="@form"  />
                                <p:commandButton value="Cancelar"  icon="ui-icon-trash" />
                            </div >
                        </div>
                    </p:tab>
                    <p:tab title="Pesquisar" id="tab02" >
                        <div class="row">
                            <div class="twelve columns"> 
                                <fieldset>
                                    <legend> <h4 style="margin:0 0 10px 0">Pesquisar</h4></legend>
                                    <div class="container_24 clearfix " >
                                        <p:outputLabel value="Cod : " styleClass="grid_3" />
                                        <p:inputText id="cod" value="#{managerSearchNature.natureWriting.cod}" styleClass="grid_8"/>
                                        <br/><br/>
                                        <p:outputLabel value="Descricao : " styleClass="grid_3" />
                                        <p:inputText id="desc" value="#{managerSearchNature.natureWriting.description}" styleClass="grid_12"/>
                                    </div>
                                    <div class="buttonAction">
                                        <p:commandButton value="Pesquisar" actionListener="#{managerSearchNature.searchNature()}" 
                                                         icon="ui-icon-search" styleClass="ui-priority-primary"
                                                         update="@form, natureTable" />
                                        <p:commandButton value="Cancelar" actionListener="#{managerSearchNature.cancelSearch()}" 
                                                         update="@form" icon="ui-icon-trash" />
                                    </div >
                                    <div class="container_24 clearfix">
                                        <p:dataTable var="nature" id="natureTable" value="#{managerSearchNature.natureWritings}" 
                                                     styleClass="grid_24" 
                                                     emptyMessage="Nenhum natureza escritura encontrado"
                                                     paginatorPosition="bottom" paginator="true" rows="5"
                                                     >
                                            <f:facet name="header">
                                               Natureza Escritura
                                            </f:facet> 
                                            <p:column headerText="Codigo" width="100">  
                                                <h:outputText value="#{nature.cod}" />  
                                            </p:column> 
                                            <p:column headerText="Descricao">  
                                                <h:outputText value="#{nature.description}" />  
                                            </p:column> 
                                            <p:column headerText="Opções" width="70">  
                                                <p:commandButton actionListener="#{managerSearchNature.resgateNature(nature)}" 
                                                                 icon="ui-icon-clipboard" style="width: 30px; height: 25px;" 
                                                                 update="@form" title="editar" />
                                            </p:column> 
                                        </p:dataTable>
                                    </div>
                                </fieldset>
                            </div>
                        </div>    
                    </p:tab>
                    <p:tab title="Editar" id="tab03" disabled="#{managerSearchNature.visibleTab}">
                        <div class="row">
                            <div class="twelve columns"> 
                                <fieldset>
                                    <legend> <h4 style="margin:0 0 10px 0">Editar Ato Cep</h4></legend>
                                    <div class="container_24 clearfix " >
                                          <p:outputLabel value="Código: " styleClass="grid_3" />
                                        <p:inputText value="#{managerSearchNature.editNatureWriting.cod}" styleClass="grid_8"/>

                                        <p:outputLabel value="Tipo Ato: " styleClass="grid_4"/>
                                        <p:autoComplete styleClass="grid_8" id="ato" style="width: 28.44%" dropdown="true" converter="actcepconverter"   
                                                        var="actCepValue" itemLabel="#{actCepValue.description}" 
                                                        itemValue="#{actCepValue}" value="#{managerSearchNature.editNatureWriting.actCep}"
                                                        completeMethod="#{managerActCep.autocomplete}" />

                                        <p:outputLabel value="Descrição: " styleClass="grid_3"/>
                                        <p:inputTextarea value="#{managerSearchNature.editNatureWriting.description}" styleClass="grid_20" />
                                    </div>
                                </fieldset>
                            </div>
                            <div class="buttonAction">
                                <p:commandButton value="Atualizar" actionListener="#{managerSearchNature.update()}"
                                                 icon="ui-icon-document" styleClass="ui-priority-primary"
                                                 update="@form" />
                                <p:commandButton value="Cancelar" actionListener="#{managerSearchNature.cancelEdit()}" 
                                                 icon="ui-icon-circle-close" update="@form" />
                            </div >
                        </div>
                    </p:tab>
                  
                </p:tabView>
            </h:form>
        </ui:define>
    </ui:composition>
</html>